package main

import (
	"fmt"
)

type student struct {
	name string
	age  int
}

/* func main(){
	stu1 := newStudent("张胜豪",18)
	stu2 := stu1 // 拷贝
	fmt.Printf("stu1:%p\t\n",*stu1)
	fmt.Printf("stu2:%p\t\n",*stu2)

} */
func main() {
	// test1()
	test2()
}
func test1() {
	m := make(map[string]*student)

	stus := []student{
		{name: "小王子", age: 18},
		{name: "娜扎", age: 23},
		{name: "大王八", age: 9000},
	}

	for _, stu := range stus {
		m[stu.name] = &stu
	}
	for k, v := range m {
		fmt.Println(k, "=>", v)
	}
}

// 因为struct没有构造方法，模拟一个结构体指针类型的构造函数(对比引用类型)
func newStudent(name string, age int) *student {
	return &student{name, age}
}

func test2() {
	// var a int = 5
	a := []int{1, 3, 4}
	fmt.Printf("%p,%v\n", &a, a)
	a[0] = 6
	fmt.Printf("%p,%v\n", &a, a)
	a[1] = 7
	fmt.Printf("%p,%v\n", &a, a)
}
